-- story_cultivation.lua - 修仙游戏修炼相关故事

return {
    -- 继续修炼节点
    {
        id = "continue_cultivation",
        title = "勤奋修炼",
        text = function(state)
            local cultivation = state.variables["player.cultivation"]
            return string.format("你沉浸在修炼中，不知不觉过去了三天。\n你的修为已经达到了%s，体内的灵气更加充沛。", cultivation)
        end,
        vars = {
            ["player.qi"] = function(state)
                return (state.variables["player.qi"] or 0) + 20
            end,
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 15
            end
        },
        choices = {
            {
                text = "尝试突破到下一层",
                next = "attempt_breakthrough"
            },
            {
                text = "出门历练",
                next = "village_outside"
            },
            {
                text = "去寻找更好的修炼地点",
                next = "find_cultivation_spot"
            }
        }
    },
    
    -- 突破境界节点
    {
        id = "attempt_breakthrough",
        title = "突破境界",
        text = function(state)
            local qi = state.variables["player.qi"] or 0
            if qi >= 30 then
                return [[你感受到体内的灵气已经达到了瓶颈。
经过一番努力，你成功突破到了练气二层！]]
            else
                return [[你尝试突破，但体内的灵气不足。
突破失败了，你感到有些疲惫。]]
            end
        end,
        vars = function(state)
            local qi = state.variables["player.qi"] or 0
            if qi >= 30 then
                return {
                    ["player.cultivation"] = "练气二层",
                    ["player.qi"] = qi - 30,
                    ["game.score"] = (state.variables["game.score"] or 0) + 30
                }
            else
                return {
                    ["player.health"] = function(state)
                        return math.max(1, (state.variables["player.health"] or 100) - 10)
                    end,
                    ["game.score"] = (state.variables["game.score"] or 0) + 5
                }
            end
        end,
        choices = {
            {
                text = "继续修炼",
                next = "continue_cultivation"
            },
            {
                text = "出门庆祝",
                next = "village_outside"
            },
            {
                text = "研究突破的经验",
                next = "study_breakthrough"
            }
        }
    },
    
    -- 寻找修炼地点节点
    {
        id = "find_cultivation_spot",
        title = "寻找修炼圣地",
        text = [[你在山林中寻找适合修炼的地方。
经过一番探索，你发现了一个灵气浓郁的山洞。
山洞深处传来微弱的光芒。]],
        vars = {
            ["game.location"] = "mysterious_cave",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 10
            end
        },
        choices = {
            {
                text = "进入山洞",
                next = "enter_cave"
            },
            {
                text = "在洞口修炼",
                next = "cultivate_at_cave_entrance"
            },
            {
                text = "返回村庄",
                next = "village_outside"
            }
        }
    },
    
    -- 进入山洞节点
    {
        id = "enter_cave",
        title = "神秘山洞",
        text = [[你进入了山洞，发现里面有一个古老的祭坛。
祭坛上放着一颗发光的珠子，散发着强大的灵气。]],
        vars = {
            ["game.discovery"] = "spirit_orb",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 20
            end
        },
        choices = {
            {
                text = "触摸发光的珠子",
                next = "touch_spirit_orb"
            },
            {
                text = "仔细观察祭坛",
                next = "examine_altar"
            },
            {
                text = "离开山洞",
                next = "find_cultivation_spot"
            }
        }
    },
    
    -- 触摸灵珠节点
    {
        id = "touch_spirit_orb",
        title = "灵珠的力量",
        text = [[你触摸了那颗发光的珠子，一股强大的灵气涌入你的体内。
你感到自己的修为在飞速提升！]],
        vars = {
            ["player.qi"] = function(state)
                return (state.variables["player.qi"] or 0) + 50
            end,
            ["player.cultivation"] = "练气三层",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 50
            end
        },
        choices = {
            {
                text = "继续探索山洞",
                next = "explore_cave_deeper"
            },
            {
                text = "带着灵珠离开",
                next = "leave_with_orb"
            },
            {
                text = "在山洞中修炼",
                next = "cultivate_in_cave"
            }
        }
    },
    
    -- 研究突破经验节点
    {
        id = "study_breakthrough",
        title = "总结经验",
        text = [[你总结了这次突破的经验，对修炼有了更深的理解。
你觉得下次突破会更加顺利。]],
        vars = {
            ["player.understanding"] = "advanced",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 10
            end
        },
        choices = {
            {
                text = "继续修炼",
                next = "continue_cultivation"
            },
            {
                text = "去村里的书店",
                next = "village_bookstore"
            }
        }
    }
}